<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class C_topupdeposit extends CI_Controller {
	function __construct(){
		parent::__construct();
	}
	public function index(){
		$data['data_bank'] = $this->m_public_function->get_banklist();
		$this->load->view('main/v_topupdeposit', $data);
	}
	function index_confirmation(){
		$this->load->view('main/v_confirmationdeposit');
	}
	function generate(){
		$jumlah = trim(@$_POST['jumlah']);
		$bank = trim(@$_POST['bank']);
		$user_id = $this->session->userdata('DX_user_id');
		$tanggal_create = date('Y-m-d H:i:s');
		$tanggal_exp = date('Y-m-d H:i:s', strtotime("+1 day"));
		$kode_used = $this->m_public_function->get_today_lastkode($tanggal_create);
		$array_kode = array();
		$a = 0;
		for($i=100;$i<=5000;$i = $i + 100){
			$array_kode[$a]=$i;
			if($kode_used !== 0){
				foreach($kode_used as $row_kodeused){
					if($i == $row_kodeused->tiket_genkode){
						unset($array_kode[$a]);
					}
				}
			}
			$a++;
		}
		$generate_kode = $array_kode[array_rand($array_kode,1)];
		$result = $this->m_public_function->generate_topupdeposit($jumlah, $user_id, $generate_kode, $tanggal_create, $tanggal_exp, $bank);
		echo $result;
	}
	function konfirmasi(){
		$kode = trim(@$_POST['kode']);
		$user_id = $this->session->userdata('DX_user_id');
		$tanggal_update = date('Y-m-d H:i:s');
		$result = $this->m_public_function->konfirmasi($kode, $user_id, $tanggal_update);
		echo $result;
	}
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */